package com.atguigu.day20.homework.h4;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/25 21:23
 * @注释
 */
public class PrintNumber {
    static int even = 2;
    static int odd = 1;

    public static synchronized void printEven() {
        for (int i = 0; i < 5; i++) {
            System.out.println("调用本轮第" + i + "个数字:" + even);
            even += 2;
        }
    }

    public synchronized void printOdd() {
        for (int i = 0; i < 5; i++) {
            System.out.println("调用本轮第" + i + "个数字:" + odd);
            odd += 2;
        }
    }
}
